/**
 * 流程管理js文件
 */
var position = {};

var Process = function (){
	
}
// 开始图标对象
Process.start= "<img src='../image/start.jpg'/>";
// 结束图标对象
Process.end = "<img src='../image/end.jpg'/>";
// 节点图标对象
Process.node="<img src='../image/node.jpg'/>";
// 连线对象
Process.line = "<img src='../image/line.png'/>";
//选择图标（清空当前选择项）
Process.select = "<img src='../image/select.jpg'/>";
// 当前选择对象
Process.currSelect = null;

Process.prototype = {
	/**
	 * 添加开始图标
	 */
	selectStart : function() {
		Process.currSelect = $(Process.start);
	},
	/**
	 * 添加结束图标
	 */
	selectEnd : function() {
		Process.currSelect = $(Process.end);
	},
	/**
	 * 添加中间环节图标
	 */
	selectNode : function() {
		Process.currSelect = $(Process.node);
	},
	/**
	 * 添加连线图标
	 */
	selectLine : function() {
		Process.currSelect = $(Process.line);
	},
	
	select:function(){
		Process.currSelect = null;
	},
	addNode : function(){
		if(!Process.currSelect){
			return;
		}
		Process.currSelect.css({ position:'absolute',  top:position.y+'px',left:position.x+'px'});
		$("#work").append(Process.currSelect);
	}
}
function mousePosition(ev){ 
	if(ev.pageX || ev.pageY){ 
		return {x:ev.pageX, y:ev.pageY}; 
	} 
	return { x:ev.clientX +	document.body.scrollLeft - document.body.clientLeft, 
		     y:ev.clientY +document.body.scrollTop - document.body.clientTop };
} 
function mouseMove(ev){ 
	ev = ev || window.event; 
	var mousePos =	mousePosition(ev); 
	position.x = mousePos.x-10;
	position.y = mousePos.y-14;
}
document.onmousedown = mouseMove;